﻿<UserControl x:Class="LiSAClient.WpfClient.View.Projects.WorkOnProject"
             xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
             xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
             xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" 
             xmlns:d="http://schemas.microsoft.com/expression/blend/2008" 
             xmlns:projects="clr-namespace:LiSAClient.WpfClient.View.Projects"
             xmlns:articleFeedback="clr-namespace:LiSAClient.WpfClient.View.Projects.ArticleFeedback"
             mc:Ignorable="d" 
             d:DesignHeight="900" d:DesignWidth="1000" MinHeight="700" MinWidth="900">
    <Grid>
        <Grid.ColumnDefinitions>
            <ColumnDefinition Width="2*"/>
            <ColumnDefinition Width="*"/>
        </Grid.ColumnDefinitions>

        <!--Overview-->
        <Grid Grid.Column="0">
            <Grid.RowDefinitions>
                <RowDefinition Height="*"/>
                <RowDefinition Height="5*"/>
            </Grid.RowDefinitions>

            <!--MetaInfo-->
            <Grid Grid.Row="0">
                <Grid.ColumnDefinitions>
                    <ColumnDefinition Width="Auto"/>
                    <ColumnDefinition Width="*"/>
                    <ColumnDefinition Width="Auto"/>
                    <ColumnDefinition Width="*"/>
                </Grid.ColumnDefinitions>
                <Grid.RowDefinitions>
                    <RowDefinition Height="Auto" />
                    <RowDefinition Height="Auto" />
                    <RowDefinition Height="Auto" />
                    <RowDefinition Height="Auto" />
                    <RowDefinition Height="20" />
                </Grid.RowDefinitions>
                <Label Grid.Column="0" Grid.Row="0" Content="Project:" Style="{StaticResource InformationCaption}"/>
                <Label Grid.Column="1" Grid.Row="0" Content="{Binding Project.Title}" Style="{StaticResource InformationContent}"/>

                <Label Grid.Column="0" Grid.Row="1" Content="Current Stage:" Style="{StaticResource InformationCaption}"/>
                <Label Grid.Column="1" Grid.Row="1" Content="{Binding Project.CurrentPhase}" Style="{StaticResource InformationContent}"/>

                <Label Grid.Column="0" Grid.Row="2" Content="Lead:" Style="{StaticResource InformationCaption}"/>
                <Label Grid.Column="1" Grid.Row="2" Content="{Binding Lead}" Style="{StaticResource InformationContent}"/>
                <StackPanel Orientation="Horizontal" Grid.Column="0" Grid.Row="3" Grid.ColumnSpan="2">
                    <Button Style="{StaticResource LoginBoxButtonStyle}" Command="{Binding RemoveDuplicatesCmd}" TabIndex="0" Content="Remove duplicates" Width="150"/>
                </StackPanel>



                <Label Grid.Column="2" Grid.Row="0" Content="Article:" Style="{StaticResource InformationCaption}"/>
                <TextBox Grid.Column="3" Grid.Row="0" Text="{Binding SelectedArticle.Name}" Style="{StaticResource InformationContentBox}" TextWrapping="Wrap"/>

                <Label Grid.Column="2" Grid.Row="1" Content="Author:" Style="{StaticResource InformationCaption}"/>
                <TextBox Grid.Column="3" Grid.Row="1" Text="{Binding SelectedArticle.Author}" Style="{StaticResource InformationContentBox}" TextWrapping="Wrap"/>

                <Label Grid.Column="2" Grid.Row="2" Content="Date:" Style="{StaticResource InformationCaption}"/>
                <Label Grid.Column="3" Grid.Row="2" Content="{Binding SelectedArticleDate}" Style="{StaticResource InformationContent}"/>

                <Label Grid.Column="2" Grid.Row="3" Content="Type:" Style="{StaticResource InformationCaption}"/>
                <ComboBox Grid.Column="3" Grid.Row="3" ItemsSource="{Binding ArticleTypes}" SelectedItem="{Binding ArticleType}" Style="{StaticResource ComboBoxInputStyle}"/>
            </Grid>

            <!--Articles-->
            <Grid Grid.Row="1">
                <DataGrid Name="ArticlesOverviewDataGrid" ItemsSource="{Binding Project.Articles}"  Style="{StaticResource DataGridStyle}"
                      AutoGenerateColumns="False" IsReadOnly="True" IsSynchronizedWithCurrentItem="True" SelectionMode="Single" SelectionUnit="FullRow" 
                     SelectedItem="{Binding SelectedArticle, Mode=TwoWay}">
                    <DataGrid.Columns>
                        <DataGridCheckBoxColumn Width="65" HeaderStyle="{StaticResource DgchStyle}" Binding="{Binding IsDuplicate, UpdateSourceTrigger=PropertyChanged}" Header="Duplicate" ElementStyle="{StaticResource DataGridCheckBoxColumnElementStyle}"/>
                        <DataGridTextColumn Width="*" HeaderStyle="{StaticResource DgchStyle}" Binding="{Binding Name}" Header="Name" ElementStyle="{StaticResource DataGridTextColumnElementStyle}" />
                        <DataGridTextColumn Width="*" HeaderStyle="{StaticResource DgchStyle}" Binding="{Binding Author}" Header="Author" ElementStyle="{StaticResource DataGridTextColumnElementStyle}" />
                        <DataGridTextColumn Width="100" HeaderStyle="{StaticResource DgchStyle}" Binding="{Binding PublicationDate}" Header="Publication Date" ElementStyle="{StaticResource DataGridTextColumnElementStyle}"/>
                    </DataGrid.Columns>
                    <DataGrid.InputBindings>
                        <MouseBinding Gesture="LeftDoubleClick" Command="{Binding ShowProject}"/>
                    </DataGrid.InputBindings>
                </DataGrid>
            </Grid>
        </Grid>

        <!--Selected Details and editing-->
        <Grid Grid.Column="1">
            <Grid.RowDefinitions>
                <RowDefinition Height="Auto"/>
                <RowDefinition Height="*"/>
            </Grid.RowDefinitions>

            <!--Selected article metainfo-->
            <Grid Grid.Row="0">
                <Grid.ColumnDefinitions>
                    <ColumnDefinition Width="Auto"/>
                    <ColumnDefinition Width="3*" />
                </Grid.ColumnDefinitions>
                <Grid.RowDefinitions>
                    <RowDefinition Height="Auto" />
                    <RowDefinition Height="Auto" />
                    <RowDefinition Height="Auto" />
                    <RowDefinition Height="Auto" />
                    <RowDefinition Height="Auto" />
                    <RowDefinition Height="Auto" />
                    <RowDefinition Height="20" />
                </Grid.RowDefinitions>


                <!--<Label Grid.Column="0" Grid.Row="4" Content="Abstract:" Style="{StaticResource InformationCaption}"/>-->
                <ScrollViewer Grid.Column="1" Grid.Row="4" HorizontalScrollBarVisibility="Disabled" VerticalScrollBarVisibility="Auto" Name="Scroller" Height="300" ScrollChanged="Scroller_ScrollChanged">
                    <TextBox  Text="{Binding SelectedArticle.Abstract}" Style="{StaticResource InformationContentBox}" TextWrapping="Wrap" Margin="0,5,5,5"
                                HorizontalAlignment="Stretch" VerticalAlignment="Stretch" Width="{Binding ElementName=Scroller, Path=ViewportWidth}"/>
                </ScrollViewer>

            </Grid>

            <!--Work on the selected article-->
            <ListBox Grid.Row="1" ItemsSource="{Binding FeedbackStages}" >
                <ListBox.ItemsPanel>
                    <ItemsPanelTemplate>
                        <StackPanel Orientation="Vertical"/>
                    </ItemsPanelTemplate>
                </ListBox.ItemsPanel>
                <ListBox.ItemTemplate>
                    <DataTemplate>
                        <articleFeedback:FeedbackStage HorizontalAlignment="Stretch"/>
                    </DataTemplate>
                </ListBox.ItemTemplate>
            </ListBox>
            <!--<articleFeedback:FeedbackStage Grid.Row="1" DataContext="{Binding FeedbackStage}"/>-->
        </Grid>
    </Grid>
</UserControl>
